// Last Update:2017-01-10 10:11:20

#include <assert.h>
#include <errno.h>

#include <iostream>
#include <string>

#include <unistd.h>

#include <leveldb/db.h>
#include <leveldb/env.h>
#include <leveldb/write_batch.h>
#include <leveldb/slice.h>
#include <leveldb/cache.h>
#ifndef HAVE_LEVELDB_FILTER_POLICY
#include <leveldb/filter_policy.h>
#endif

using namespace std;

int main(int argc, const char *argv[])
{
  leveldb::Options options;
  options.create_if_missing = true;
  string dir("./omap");

  leveldb::DB *db;
  leveldb::Status status = leveldb::DB::Open(options, dir, &db);
  if (!status.ok())
    return -EIO;

  string key("hello");
  string value("world");
  status = db->Put(leveldb::WriteOptions(), key, value);
  assert(status.ok());

  string getvalues;
  status = db->Get(leveldb::ReadOptions(), key, &getvalues);
  assert(status.ok());
  cout << getvalues << endl;

  delete db;

  return 0;
}
